package com.fortune.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.fortune.base.BaseAPIExcution;

import springfox.documentation.annotations.ApiIgnore;

import java.io.IOException;

@RestController
@ApiIgnore
@RequestMapping("error")
public class ErrorController {
	@RequestMapping(value="login")
	public BaseAPIExcution<Void> notLogin(HttpServletResponse response){
			response.setStatus(HttpStatus.UNAUTHORIZED.value());
		return new ErrorExcution("登录失效，请重新登陆");
	}
	@RequestMapping(value="timeOut")
	public BaseAPIExcution<Void> timeOut(HttpServletResponse response){
		response.setStatus(HttpStatus.UNAUTHORIZED.value());
		return new ErrorExcution("登录超时，请重新登陆");
	}
	@RequestMapping(value="kickOut")
	public BaseAPIExcution<Void> kickOut(HttpServletResponse response){
		response.setStatus(HttpStatus.UNAUTHORIZED.value());
		return new ErrorExcution("此账号已被登陆");

	}
	@RequestMapping(value="permission")
	public ModelAndView noPermission(HttpServletResponse response){
		response.setStatus(HttpStatus.FORBIDDEN.value());
		return null;
	/*	return new ErrorExcution("您无权限执行此操作");*/
	}
	
	private static class ErrorExcution extends BaseAPIExcution<Void>{
		public ErrorExcution(String msg) {
			this.status=false;
			this.msg=msg;
		}
	}
}
